package xiang.controller;

import com.alibaba.csp.sentinel.annotation.SentinelResource;
import com.xiang.utils.AjaxResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import xiang.service.InfoService;

/**
 * @author xiangtianlei
 * @date 2024/04/16
 */
@RestController
@RequestMapping("info")
public class InfoController {

    @Autowired
    InfoService infoService;

    @GetMapping("getInfo")
    public AjaxResult getInfo() throws InterruptedException {
        Thread.sleep(100);
        return infoService.getInfo();
    }

    @GetMapping("{infoId}")
    @SentinelResource("hot")
    public AjaxResult getInfoByInfoId(@PathVariable("infoId") Long infoId) {
        return AjaxResult.success(infoId);
    }
}
